#include <bits/stdc++.h>

#include <atcoder/all>
#define LL long long
using namespace std;
using namespace atcoder;

struct SegmentTree {
  struct Node {
    int l, r;
    int black_cnt;
    int ch[2];
    Node() {
      l = r = black_cnt = 0;
      ch[0] = ch[1] = 0;
    }
    bool AllBlack() {
      return r - l + 1 == black_cnt;
    }
    void ColorBlack() {
      black_cnt = r - l + 1;
    }
    int GetM() {
      return (l + r) >> 1;
    }
  };

  vector<Node> tree;

  SegmentTree(int N) {
    tree.resize(2);
    tree[1].l = 1;
    tree[1].r = N;
    tree[1].black_cnt = 0;
  }

  void Color(int now, int ll, int rr) {
    if (tree[now].AllBlack()) {
      return;
    }
    if (tree[now].l >= ll && tree[now].r <= rr) {
      tree[now].ColorBlack();
      return;
    }
    int m = tree[now].GetM();

    if (m < rr) {
      if (tree[now].ch[1] == 0) {
        tree.emplace_back(Node());
        tree.back().l = m + 1;
        tree.back().r = tree[now].r;
        tree[now].ch[1] = tree.size() - 1;
      }
      Color(tree[now].ch[1], ll, rr);
    }
    if (ll <= m) {
      if (tree[now].ch[0] == 0) {
        tree.emplace_back(Node());
        tree.back().l = tree[now].l;
        tree.back().r = m;
        tree[now].ch[0] = tree.size() - 1;
      }
      Color(tree[now].ch[0], ll, rr);
    }
    tree[now].black_cnt = tree[tree[now].ch[0]].black_cnt + tree[tree[now].ch[1]].black_cnt;
  }

  int GetRootBlackCnt() {
    return tree[1].black_cnt;
  }
};

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int N, Q;

  cin >> N >> Q;

  SegmentTree st(N);
  for (int i = 0; i < Q; i++) {
    int L, R;
    cin >> L >> R;
    st.Color(1, L, R);
    cout << N - st.GetRootBlackCnt() << "\n";
  }
  return 0;
}
